package com.wolfalpha.lwtool.adapter;

import java.util.List;
import com.wolfalpha.lwtool.R;
import com.wolfalpha.lwtool.vo.LWJob;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 适配器
 * @author ttStudio
 *
 */
public class MyJobAdapter extends BaseAdapter {  
  
    private List<LWJob> data;  
    private LayoutInflater layoutInflater;  
    public MyJobAdapter(Context context,List<LWJob> data){  
        this.data=data;  
        this.layoutInflater=LayoutInflater.from(context);  
    }  
    /** 
     * 组件集合，对应list.xml中的控件 
     * @author Administrator 
     */  
    public final class Zujian{  
        public TextView mjtitle;  
        public TextView mjdate;  
        public TextView mjstyle;  
        public TextView mjdetail;  
    }  
    /**
     * 获取数量
     */
    @Override  
    public int getCount() {  
        return data.size();  
    }  
    /** 
     * 获得某一位置的数据 
     */  
    @Override  
    public Object getItem(int position) {  
        return data.get(position);  
    }  
    /** 
     * 获得唯一标识 
     */  
    @Override  
    public long getItemId(int position) {  
        return position;  
    }  
    /**
     * 获取识图
     */
    @Override  
    public View getView(int position, View convertView, ViewGroup parent) {  
        Zujian zujian=null;  
        if(convertView==null){  
            zujian=new Zujian();  
            //获得组件，实例化组件  
            convertView=layoutInflater.inflate(R.layout.mjob_item, null);  
            zujian.mjtitle=(TextView)convertView.findViewById(R.id.mjtitle);  
            zujian.mjdate=(TextView)convertView.findViewById(R.id.mjdate);  
            zujian.mjstyle=(TextView)convertView.findViewById(R.id.mjstyle);  
            zujian.mjdetail=(TextView)convertView.findViewById(R.id.mjdetail);  
            convertView.setTag(zujian);  
		} else {
            zujian=(Zujian)convertView.getTag();  
        }  
        //绑定数据  
        zujian.mjtitle.setText((String)data.get(position).getName());  
        zujian.mjdate.setText(data.get(position).getIs_closed() == 0?"在招":"停招");  
        zujian.mjstyle.setText(String.valueOf(data.get(position).getCategory()));  
        zujian.mjdetail.setText((String)data.get(position).getIntro());  
        return convertView;  
    }
  
}  